﻿//json对象转换
$.fn.serializeObject = function () {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function () {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};
/***************************页面基础操作功能***********************************************/

//添加 模态打开
function add() {
    $("#mmXgmodal").modal({
        remote: "add"
    });
}
//修改 模态打开
function edit() {
    $("#mmXgmodal").modal({
        remote: "edit"
    });
}

//添加新页面
function addopen() {
    window.location.href = "add";
}
//修改新页面
function editopen() {
    window.location.href = "add";
}

//保存数据
function save() {
    $.ajax({
        type: "POST",
            url: "add",
            data: $("#form1").serialize(),
            success: function (msg) {
                $("#mmXgmodal").on("hidden.bs.modal", function () {
                    $(this).removeData("bs.modal");
                });
                $("#mmXgmodal").modal('hide');
                $("#btnsearch").click();
            }
    });
}
//删除 单条
function mydelete(_id) {
    $.ajax({
        type: "POST",
        url: "delete",
        data: "id=" + _id,
        success: function (msg) {
            if (msg == "true") {
                $("#btnsearch").click();
            }
            else {
                alert(msg);
            }
        }
    });
}
//删除 多条
function mydeletes(_ids) {
    $.ajax({
        type: "POST",
        url: "delete",
        data: "ids=" + _ids,
        success: function (msg) {
            if (msg == "true") {
                $("#btnsearch").click();
            }
            else {
                alert(msg);
            }
        }
    });
}
//按条件导出
function myexport(_ids) {
    //$("#formSearch").serialize()
}

//打印 
function myprints() {
    window.print();
}

//返回
function myback() {

    window.history.back();
}